package cn.com.nes.site.controller.fault;

import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.dto.fault.GetFaultListByProtocolIdDto;
import cn.com.nes.site.entity.vo.monitor.BrandVo;
import cn.com.nes.site.service.fault.FaultTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/v2/faultType")
public class FaultTypeController {

    @Autowired
    private FaultTypeService faultTypeService;

    /**
     * 获取故障类型 - 下拉框 - 厂商平台字典
     * @param vo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "getFaultType", method = RequestMethod.POST)
    @ResponseBody
    public PageData getFaultType(@RequestBody BrandVo vo)  throws Exception{
        String manufactureId = vo.getUserInfo().getNes_companyId();
        //todo 怎么判断是否是代理商
        Byte isAgent = 0;
        if("01".equals( vo.getUserInfo().getCompanyType())) {
            isAgent =0;
        }else if("02".equals( vo.getUserInfo().getCompanyType())){
            isAgent =1;
        }else{
            isAgent=0;
        }
        List<GetFaultListByProtocolIdDto> dtos = faultTypeService.getFaultType(manufactureId,isAgent);
        return PageData.ok(dtos,true);
    }

    /**
     * 获取设备类型 - 下拉框 - 字典 
     */
    // TODO: 2024/3/4 获取设备类型 - 下拉框 - 字典 - 待定

}
